package com.gitee.swsk33.xmlbased;

import com.gitee.swsk33.xmlbased.model.Cat;
import com.gitee.swsk33.xmlbased.service.MessageService;
import com.gitee.swsk33.xmlbased.service.SendService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Main {

	public static void main(String[] args) {
		// 读取xml文件创建IoC容器实例
		ApplicationContext context = new ClassPathXmlApplicationContext("/beans.xml");
		// 获取MessageService对象
		MessageService messageService = context.getBean("messageService", MessageService.class);
		// 然后就可以使用了！
		messageService.print();

		// 获取SendService对象
		SendService sendService = context.getBean("sendService", SendService.class);
		// 调用
		sendService.send();

		// 获取cat对象
		Cat cat = context.getBean("cat", Cat.class);
		// 打印
		System.out.println(cat);
	}

}